<template>
  <a-card :bordered='false'>
    <!-- 查询区域 -->
    <search ref='search' :config='searchConfig' @search='search' @getHeight='getHeight' />
    <!-- table区域-begin -->
    <div class='page_table'>
      <vxe-grid
        ref='xGrid'
        :border='true'
        :resizable='true'
        :showOverflow='true'
        size='mini'
        :loading='loading'
        :height='pageHeight-seachHeight-90'
        :align='left'
        :columns='columns'
        :data='dataSource'
        :toolbar-config='tableToolbar'
       :checkbox-config="checkboxConfig"
        v-bind='vexConfig'
        @checkbox-change='selectChangeEvent'
        @checkbox-all='selectChangeEvent'
      >
        <template #toolbar_buttons>
          <div class='table-operator'>
            <a-button v-has="'storeShipment:add'" @click='handleAdd'>新增</a-button>
            <a-button v-has="'storeShipment:delete'" @click='batchDel'>删除</a-button>
            <a-button v-has="'storeShipment:synchronization'"  @click=''>同步</a-button>
            <a-button v-has="'storeShipment:export'"  @click=''>导出</a-button>
          </div>
        </template>
        <template #customerCode='{ row,rowIndex }'>
          <a @click="handledetal(row, '详情', true, true)">{{ row.customerCode }}</a>
        </template>
        <template #update='{ row }'>
          <a-switch :checked='row.status' size='small' @change='handleStatus(row,$event)' />
        </template>
        <template #action='{ row }'>
          <a v-has="'storeShipment:update'" @click='handleEdit(row,"编辑")'>编辑</a>
          <a-divider type='vertical' />
          <a v-has="'business:log'" href='javascript:' @click='handleBusiness("起送配置",row)'>日志</a>
        </template>
        <template #pager>
          <vxe-pager
            :layouts="['Total', 'PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump','Sizes', 'FullJump']"
            :currentPage.sync='ipagination.current'
            :page-size.sync='ipagination.pageSize'
            :total='ipagination.total'
            :pageSizes='ipagination.pageSizeOptions'
            @page-change='handlePageChange'>
          </vxe-pager>
        </template>
      </vxe-grid>
    </div>
    <form-add-edit ref='formAdd' @ok='modalFormOk'></form-add-edit>
    <business-log ref='businessLog'></business-log>
    <store-shipment-add ref='modalForm' @ok='modalFormOk'></store-shipment-add>
  </a-card>
</template>

<script>
import Vue from 'vue'
import search from '@comp/view/base-crud/search/Search'
import FormAddEdit from '@comp/view/base-crud/form/FormAddEdit'
import { PageListMixin } from '@/mixins/PageListMixin'
import { getAction } from '@/api/manage'
import { filterObj } from '@/utils/util'
import JTreeSelect from '@/components/cn-form/JTreeSelect'
import storeShipmentAdd from '@views/mdm/config-center/modules/StoreShipmentModal'

export default {
  name: 'product-list',
  mixins: [PageListMixin],
  components: {
    FormAddEdit,
    JTreeSelect,
    search,
    storeShipmentAdd
  },
  data() {
    return {

      description: '起运量',
      importExcelUrl: window._CONFIG['domianURL'] + '/cnProductController/importExcel',
      searchConfig: [
        {
          // label:'订单编号',
          type: 'input',
          name: 'customerCode',
          placeholder: '经销商编号'
        },
        {
          type: 'input',
          name: 'customerName',
          placeholder: '经销商名称'
        },
        {
          type: 'input',
          name: 'liftingCapacity',
          placeholder: '起送量'
        },
        {
          type: 'j-select',
          dictCode: 'user_status',
          name: 'status',
          placeholder: '状态'
        }
      ],
      //列设置
      settingColumns: [],
      tablePage: {
        total: 0,
        currentPage: 1,
        pageSize: 10
      },
      //列定义
      columns: [
        { type: 'checkbox', width: 60, fixed: 'left' },
        {
          title: '经销商编号',
          field: 'customerCode',
          minWidth: 80,
          fixed: 'left',
          slots: { default: 'customerCode' }
        },
        {
          title: '经销商名称',
          minWidth: 80,
          field: 'customerName'
        },
        {
          title: '配送日期',
          minWidth: 80,
          field: 'deliveryDate'
        },
        {
          title: '起送量',
          align: 'left',
          minWidth: 80,
          field: 'liftingCapacity'
        },
        {
          title: '备注',
          width: 120,
          minWidth: 80,
          field: 'remarks'
        },
        {
          title: '创建人',
          minWidth: 80,
          field: 'createName'
        },
        {
          title: '创建时间',
          minWidth: 80,
          field: 'createTime'
        },
        {
          title: '更新人',
          align: 'left',
          minWidth: 80,
          field: 'updateName'
        },
        {
          title: '更新时间',
          align: 'left',
          minWidth: 80,
          field: 'updateTime'
        },
        {
          title: '状态',
          align: 'left',
          field: 'status',
          width: 60,
          fixed: 'right',
          minWidth: 80,
          slots: { default: 'update' }
        },
        {
          title: '操作',
          field: 'action',
          fixed: 'right',
          minWidth: 120,
          slots: { default: 'action' }
        }
      ],
      isAllChecked: null,
      isIndeterminate: [],
      selectRecords: [],
      url: {
        list: window._CONFIG['domianURL'] + '/liftingcapacityconfig/cnLiftingCapacityConfig/findPageList',
        delete: window._CONFIG['domianURL'] + '/liftingcapacityconfig/cnLiftingCapacityConfig/delete',
        detail: window._CONFIG['domianURL'] + '/liftingcapacityconfig/cnLiftingCapacityConfig/getInfo',
        deleteBatch: window._CONFIG['domianURL'] + '/liftingcapacityconfig/cnLiftingCapacityConfig/deleteBatch',
        startOrStopUrl: window._CONFIG['domianURL'] + '/liftingcapacityconfig/cnLiftingCapacityConfig/startOrStop'
      }
    }
  },
  created() {
  },
  methods: {
    // handleView: async function (row) {
    //   this.$refs.modalForm.edit(row)
    //   this.$refs.modalForm.title = '查看自定义产品组'
    //   this.$refs.modalForm.disableSubmit = true
    // },
    handleEdit: async function (row) {
      this.$refs.modalForm.edit(row)
      this.$refs.modalForm.title = '编辑'
      this.$refs.modalForm.disableSubmit = false
    },
    handledetal: async function (row) {
      this.$refs.modalForm.edit(row)
      this.$refs.modalForm.title = '详情'
      this.$refs.modalForm.disableSubmit = true
    },
    // async handleAdd(record = {}, title = '新增', disabled = false, disableSubmit = false) {
    //   if (record.id && this.url.detail) {
    //     const res = await getAction(this.url.detail, { id: record.id })
    //     if (res.success) {
    //       if (res.result) {
    //         record = res.result
    //       }
    //     }
    //   }
    //   let config = {
    //     title: title,
    //     width: 500,
    //     addOrUpdateUrl: `${window._CONFIG['domianURL']}/liftingcapacityconfig/cnLiftingCapacityConfig/saveOrUpdate`,  //审核地址
    //     method: 'post',
    //     list: [
    //       {
    //         label: '经销商编号',
    //         type: 'input',
    //         disabled: disabled,
    //         placeholder: '经销商编号',
    //         name: 'customerCode',  // 后台接受字段
    //         check: { rules: [{ required: true, message: '' }] }
    //       },
    //       {
    //         label: '经销商名称',
    //         type: 'input',
    //         disabled: disabled,
    //         placeholder: '经销商名称',
    //         name: 'customerName'  // 后台接受字段
    //         // check: { rules: [{ required: true, message: '经销商名称' }] }
    //       },
    //       {
    //         label: '起送量',
    //         type: 'input',
    //         disabled: disabled,
    //         placeholder: '请输入',
    //         name: 'liftingCapacity'  // 后台接受字段
    //       },
    //       {
    //         label: '配送日期',
    //         disabled: disabled,
    //         type: 'a-select-multiple',
    //         option: [
    //           {
    //             dictDataDesc: '星期一',
    //             dictDataCode: '星期一'
    //           },
    //           {
    //             dictDataDesc: '星期二',
    //             dictDataCode: '星期二'
    //           },
    //           {
    //             dictDataDesc: '星期三',
    //             dictDataCode: '星期三'
    //           },
    //           {
    //             dictDataDesc: '星期四',
    //             dictDataCode: '星期四'
    //           },
    //           {
    //             dictDataDesc: '星期五',
    //             dictDataCode: '星期五'
    //           }, {
    //             dictDataDesc: '星期六',
    //             dictDataCode: '星期六'
    //           },
    //           {
    //             dictDataDesc: '星期日',
    //             dictDataCode: '星期日'
    //           },],
    //         placeholder: '配送日期',
    //         name: 'deliveryDate'  // 后台接受字段
    //       },
    //       {
    //         label: '备注',
    //         type: 'textarea',
    //         disabled: disabled,
    //         placeholder: '备注',
    //         name: 'remarks'  // 后台接受字段
    //         // check: { rules: [{ required: true, message: '备注' }] },
    //       }
    //     ]
    //   }
    //   this.$refs.formAdd.edit(record, config)
    //   this.$refs.formAdd.disableSubmit = disableSubmit
    // }
  }

}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>